package com.aimkst;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.BV.LinearGradient.LinearGradientPackage;
import org.devio.rn.splashscreen.SplashScreenReactPackage;
import com.microsoft.codepush.react.CodePush;
import cn.jpush.reactnativejpush.JPushPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {
    // 设置为 true 将不会弹出 toast
    private boolean SHUTDOWN_TOAST = true;
    // 设置为 true 将不会打印 log
    private boolean SHUTDOWN_LOG = true;

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    protected String getJSBundleFile() {
        return CodePush.getJSBundleFile();
    }

    @Override
    public boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
    }

    //Android_Staging       58xX_IpEdYkwfcnAzclI8uOS7Efk109eccaa-8fce-4e2a-9d47-f89d6a4025db
    //Android_Production    UfwE3FKK2yE6fWS-CJGGyaOC0DPE109eccaa-8fce-4e2a-9d47-f89d6a4025db
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
		  new SplashScreenReactPackage(),
		  new LinearGradientPackage(),
		  new CodePush("58xX_IpEdYkwfcnAzclI8uOS7Efk109eccaa-8fce-4e2a-9d47-f89d6a4025db", MainApplication.this, BuildConfig.DEBUG),
		  new JPushPackage(SHUTDOWN_TOAST, SHUTDOWN_LOG),
		  new RNDeviceInfo()
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}
